Atomic Operation Predictor

ABSTRACT

In an embodiment, a processor comprises an atomic predictor circuit to predict whether or not an atomic operation will complete successfully. The prediction may be used when a subsequent load operation to the same memory location as the atomic operation is executed, to determine whether or not to forward store data from the atomic operation to the subsequent load operation. If the prediction is successful, the store data may be forwarded. If the prediction is unsuccessful, the store data may not be forwarded. In cases where an atomic operation has been failing (not successfully performing the store operation), the prediction may prevent the forwarding of the store data and thus may prevent a subsequent flush of the load.

This application is a continuation of U.S. patent application Ser. No.16/906,396, filed on Jun. 19, 2020 and now U.S. Pat. No. 11,119,767. Theabove application is incorporated by reference in its entirety.

BACKGROUND Technical Field

Embodiments described herein are related to processors and, moreparticularly, to performing atomic operations in processors.

Description of the Related Art

A processor executes instructions defined in an instruction setarchitecture (ISA) that is implemented by the processor. The ISA definesthe coding of each instruction (e.g., how the instruction appears inmemory), the operation of the instruction, and the resulting updates toarchitectural state. One type of instruction or instructions that isoften included in the ISA is an atomic instruction. The atomicinstruction generally includes a load from a memory location, a dataoperation on the load data, and a store operation to write the memorylocation. The store operation can be conditional based on the result ofthe data operation. For example, a compare and swap atomic instructioncompares the load data to data in another register operand of theinstruction and, if the comparison result is equal, the store isperformed. If the comparison result is not equal, the store is notperformed. Another example is a test and set instruction, which teststhe load data for a predetermined value (e.g. zero) and writes anothervalue (e.g. one) to the location if the predetermined value is in thememory location. A test and clear instruction can be supported as well,that tests for one and writes zero. Still other examples performarithmetic operations on the load data and write the result as the storedata. Additionally, as implied by the name, the atomic instruction isdefined to perform the load and the store atomically with respect toother memory operations. Another processor (or any other memory-writingagent) is not permitted to update the memory location between the loadand the store.

Since the store is conditional based on the result of the dataoperation, a subsequent load operation to the memory location that isexecuted by the processor (e.g., a load operation derived from aninstruction that is after the atomic instruction in program order)should either receive the data written by the store operation (if thestore is performed) or the data that was in the memory location prior toexecution of the atomic instruction (if the store is not performed).Most atomic instruction execute successfully, performing the update.Accordingly, some processors are designed to forward the data from thestore speculatively for the subsequent load operation to improveperformance. If the atomic instruction is later found to have failed(e.g. the store is not performed), the processor is flushed at thesubsequent load operation and the corresponding instructions arerefetched. However, there are some code sequences in which an atomicinstruction is biased to fail (e.g. the atomic instruction is morelikely to fail, not performing the store, than to succeed and performthe store). In such cases, the speculative forwarding and flushing canreduce performance and unnecessarily consume power.

SUMMARY

In an embodiment, a processor comprises an atomic predictor circuit topredict whether or not an atomic operation will complete successfully.The prediction may be used when a subsequent load operation to the samememory location as the atomic operation is executed, to determinewhether or not to forward the store data (that is, the data to bewritten to the memory location in the event that the atomic operation issuccessful). If the prediction is successful, the store data may beforwarded. If the prediction is unsuccessful, the store data may not beforwarded. In cases where an atomic operation has been failing (notsuccessfully performing the store operation), the prediction may preventthe forwarding of the store data and thus may prevent a subsequent flushof the load.

BRIEF DESCRIPTION OF THE DRAWINGS

The following detailed description refers to the accompanying drawings,which are now briefly described.

FIG. 1 is a block diagram of one embodiment of a processor.

FIG. 2 is a flowchart illustrating certain operations of one embodimentof the processor shown in FIG. 1.

FIG. 3 is a block diagram of one embodiment of an atomic predictorcircuit shown in FIG. 1.

FIG. 4 is a flowchart illustrating operation of one embodiment of theatomic predictor circuit shown in FIG. 3.

FIG. 5 is a block diagram of another embodiment of an atomic predictorcircuit shown in FIG. 1.

FIG. 6 is a flowchart illustrating operation of one embodiment of theatomic predictor circuit shown in FIG. 5.

FIG. 7 is a block diagram of one embodiment of a system.

FIG. 8 is a block diagram of one embodiment of a computer accessiblestorage medium.

FIG. 9 is a flowchart illustrating certain operations of one embodimentof the processor shown in FIG. 1.

While embodiments described in this disclosure may be susceptible tovarious modifications and alternative forms, specific embodimentsthereof are shown by way of example in the drawings and will herein bedescribed in detail. It should be understood, however, that the drawingsand detailed description thereto are not intended to limit theembodiments to the particular form disclosed, but on the contrary, theintention is to cover all modifications, equivalents and alternativesfalling within the spirit and scope of the appended claims. The headingsused herein are for organizational purposes only and are not meant to beused to limit the scope of the description. As used throughout thisapplication, the word “may” is used in a permissive sense (i.e., meaninghaving the potential to), rather than the mandatory sense (i.e., meaningmust). Similarly, the words “include”, “including”, and “includes” mean“including, but not limited to.” As used herein, the terms “first,”“second,” etc. are used as labels for nouns that they precede, and donot imply any type of ordering (e.g., spatial, temporal, logical, etc.)unless specifically stated.

Within this disclosure, different entities (which may variously bereferred to as “units,” “circuits,” other components, etc.) may bedescribed or claimed as “configured” to perform one or more tasks oroperations. This formulation—[entity] configured to [perform one or moretasks]—is used herein to refer to structure (i.e., something physical,such as an electronic circuit). More specifically, this formulation isused to indicate that this structure is arranged to perform the one ormore tasks during operation. A structure can be said to be “configuredto” perform some task even if the structure is not currently beingoperated. A “clock circuit configured to generate an output clocksignal” is intended to cover, for example, a circuit that performs thisfunction during operation, even if the circuit in question is notcurrently being used (e.g., power is not connected to it). Thus, anentity described or recited as “configured to” perform some task refersto something physical, such as a device, circuit, memory storing programinstructions executable to implement the task, etc. This phrase is notused herein to refer to something intangible. In general, the circuitrythat forms the structure corresponding to “configured to” may includehardware circuits. The hardware circuits may include any combination ofcombinatorial logic circuitry, clocked storage devices such as flops,registers, latches, etc., finite state machines, memory such as staticrandom access memory or embedded dynamic random access memory, customdesigned circuitry, analog circuitry, programmable logic arrays, etc.Similarly, various units/circuits/components may be described asperforming a task or tasks, for convenience in the description. Suchdescriptions should be interpreted as including the phrase “configuredto.”

The term “configured to” is not intended to mean “configurable to.” Anunprogrammed FPGA, for example, would not be considered to be“configured to” perform some specific function, although it may be“configurable to” perform that function. After appropriate programming,the FPGA may then be said to be “configured” to perform that function.

Reciting in the appended claims a unit/circuit/component or otherstructure that is configured to perform one or more tasks is expresslyintended not to invoke 35 U.S.C. § 112(f) interpretation for that claimelement. Accordingly, none of the claims in this application as filedare intended to be interpreted as having means-plus-function elements.Should Applicant wish to invoke Section 112(f) during prosecution, itwill recite claim elements using the “means for” [performing a function]construct.

In an embodiment, hardware circuits in accordance with this disclosuremay be implemented by coding the description of the circuit in ahardware description language (HDL) such as Verilog or VHDL. The HDLdescription may be synthesized against a library of cells designed for agiven integrated circuit fabrication technology, and may be modified fortiming, power, and other reasons to result in a final design databasethat may be transmitted to a foundry to generate masks and ultimatelyproduce the integrated circuit. Some hardware circuits or portionsthereof may also be custom-designed in a schematic editor and capturedinto the integrated circuit design along with synthesized circuitry. Theintegrated circuits may include transistors and may further includeother circuit elements (e.g. passive elements such as capacitors,resistors, inductors, etc.) and interconnect between the transistors andcircuit elements. Some embodiments may implement multiple integratedcircuits coupled together to implement the hardware circuits, and/ordiscrete elements may be used in some embodiments. Alternatively, theHDL design may be synthesized to a programmable logic array such as afield programmable gate array (FPGA) and may be implemented in the FPGA.

As used herein, the term “based on” or “dependent on” is used todescribe one or more factors that affect a determination. This term doesnot foreclose the possibility that additional factors may affect thedetermination. That is, a determination may be solely based on specifiedfactors or based on the specified factors as well as other, unspecifiedfactors. Consider the phrase “determine A based on B.” This phrasespecifies that B is a factor used to determine A or that affects thedetermination of A. This phrase does not foreclose that thedetermination of A may also be based on some other factor, such as C.This phrase is also intended to cover an embodiment in which A isdetermined based solely on B. As used herein, the phrase “based on” issynonymous with the phrase “based at least in part on.”

Similarly, as used herein, the term “responsive to” or “in response to”is used to describe one or more factors that may contribute to causing aresult. This term does not foreclose the possibility that additionalfactors may affect the causation, either independently or jointly withthe specified factors. That is, a result may be solely responsive to thespecified factors or responsive to the specified factors and/or other,unspecified factors. Consider the phrase “perform A responsive to B.”This phrase specifies that B is a factor in causing A or that affectsthe causation of A. This phrase does not foreclose that the causation ofA may responsive to some other factor, such as C, independent of B orjointly with B. This phrase is also intended to cover an embodiment inwhich A is caused solely responsive to B. As used herein, the phrase“responsive to” is synonymous with the phrase “responsive at least inpart to.” Similarly, the phrase “in response to” is synonymous with thephrase “at least in part in response to.”

This specification includes references to various embodiments, toindicate that the present disclosure is not intended to refer to oneparticular implementation, but rather a range of embodiments that fallwithin the spirit of the present disclosure, including the appendedclaims. Particular features, structures, or characteristics may becombined in any suitable manner consistent with this disclosure.

This specification may use the words “a” or “an” to refer to an element,or “the” to refer to the element. These words are not intended to meanthat there is only one instance of the element. There may be more thanone in various embodiments. Thus, “a”, “an”, and “the” should beinterpreted to mean “one or more” unless expressly described as onlyone.

This specification may describe various components, units, circuits,etc. as being coupled. In some embodiments, the components, units,circuits, etc. may be coupled if they are electrically coupled (e.g.directly connected or indirectly connected through one or more othercircuits) and/or communicatively coupled.

DETAILED DESCRIPTION OF EMBODIMENTS

Turning now to FIG. 1, a block diagram of one embodiment of a processor12 is shown. In the illustrated embodiment, the processor 12 includes afetch address generation circuit 14, an instruction cache (“ICache”) 18,a decode/map unit 22 (including a reorder buffer (ROB) 20), a branchprediction unit 26, one or more reservation stations 24A-24N, one ormore execution units 28A-28B, a register file 30, a data cache(“DCache”) 16, and a load/store unit (LSU) 42. The LSU 42 includes aload queue (LQ) 30, a store queue (SQ) 32, an atomic predictor (AP)circuit 36 coupled to the SQ 32, and an execution circuit 34 coupled tothe AP circuit 36, the LQ 30, and the SQ 32.

The fetch address generation circuit 14 is coupled to the ICache 18,which is coupled to the decode/map unit 22, which is coupled to thereservation stations 24A-24N. The reservation stations 24A-24B arecoupled to the execution units 28A-28B as shown in FIG. 1, and thereservation station 24N is coupled to the LSU 42. The reservationstations 24A-24N are also coupled to the register file 30, which iscoupled to the execution units 28A-28B and the LSU 42. The LSU 42 isalso coupled to the DCache 16, which is coupled to the register file 30.The branch prediction unit 26 is coupled to the fetch address generationcircuit 14. One or more of the execution units 28A-28B may be configuredto provide a redirect to the fetch address generation circuit 14 and thedecode/map unit 22 (e.g. in the event of a branch misprediction or othermicroarchitectural exception, in an embodiment). The LSU 42 may providea flush indication to the fetch address generation circuit 14 and thedecode/map unit 22 in the illustrated embodiment. Alternatively, theflush indication may be provided to the decode/map unit 22, which mayflush the ops after the flush point and provide a refetch address to thefetch address generation circuit 14.

The fetch address generation circuit 14 may be configured to generatefetch addresses (fetch PCs) to fetch instructions from the ICache 18 forexecution by the processor 12. The fetch address generation circuit 14may implement various prediction structures to predict the fetch path.For example, a next fetch predictor may be used to predict fetchaddresses based on previously executed instructions. In such anembodiment, the branch prediction unit 26 may be used to verify the nextfetch prediction. Alternatively, the branch prediction unit 26 may beused to predict next fetch addresses if the next fetch predictor is notused.

The branch prediction unit 26 may include one or more branch predictorssuch as a branch direction predictor, an indirect branch predictor, anda return address stack predictor. Various embodiments may include anysubset of the above branch predictors and/or other predictors. Thebranch direction predictor may be configured to predict the taken/nottaken result for conditional branches. Based on the taken/not takenresult, the next fetch address may be either the branch target addressor the next sequential address. The branch target address may be theaddress specified by the branch instruction (or more briefly, branch) towhich fetching is to be directed when the branch is taken (or is alwaysthe location to which fetching is to be directed, for unconditionalbranches). The next sequential address may be the address thatnumerically follows the PC of the branch, and may be the next fetchaddress if the branch is not taken (similar to non-branch instructions,which are fetched in sequential order). The return address stack maypredict the fetch addresses for return instructions, based on previouscall instructions. The call and return instructions may be used, e.g. tocall and return from subroutines/functions, etc. The call instructionmay push a return address on the stack (e.g. to the next sequentialinstruction after the call), and the return instruction may pop the topof the stack to generate the return address. The stack may be in memory,or may be simulated via a register written by the call instruction andread by the return instruction. The indirect branch predictor maypredict the target address of an indirect branch instruction. In anembodiment, the indirect branch predictor may be a Tagged Geometric(TAGE)-style branch predictor which has multiple memories. A base memorymay be indexed by the PC or a hash of the PC, and other memories may beindexed by the PC hashed with different amounts of branch history. Thebase memory may not be tagged, but the other memories may be tagged. Ifa tag hit is detected in one or more of the other memories, the branchtarget address may be predicted to be the target address from the memorythat is indexed with the largest amount of history and that is also atag hit for the branch. If no tag hit is detected, the branch targetaddress may be predicted to be the target address from the base memory.Other embodiments may implement other types of indirect branchpredictors. For example, a single table indexed by branch PC and branchhistory, or simply branch PC, may be used. A single tagged table may beused.

The decode/map unit 22 may be configured to decode the fetchedinstructions from the ICache 18 into instruction operations. In someembodiments, a given instruction may be decoded into one or moreinstruction operations, depending on the complexity of the instruction.Particularly complex instructions may be microcoded, in someembodiments. In such embodiments, the microcode routine for theinstruction may be coded in instruction operations. In otherembodiments, each instruction in the instruction set architectureimplemented by the processor 12 may be decoded into a single instructionoperation, and thus the term “instruction operation” may be essentiallysynonymous with “instruction” in such embodiments (although it may bemodified in form by the decoder). The term “instruction operation” maybe more briefly referred to herein as “operation” or “op.”

The decode/map unit 22 may be configured to map the ops to speculativeresources (e.g. physical registers) to permit out-of-order and/orspeculative execution, and may dispatch the ops to the reservationstations 24A-24N. The ops may be mapped to physical registers in theregister file 30 from the architectural registers used in thecorresponding instructions. That is, the register file 30 may implementa set of physical registers that may be greater in number than thearchitected registers specified by the instruction set architectureimplemented by the processor 12. The decode/map unit 22 may manage themapping of the architected registers to physical registers. There may beseparate physical registers for different operand types (e.g. integer,vector, floating point, etc.) in an embodiment. In other embodiments,the physical registers may be shared over operand types. The decode/mapunit 22 may also be responsible for tracking the speculative executionand retiring ops or flushing misspeculated ops. The ROB 20 may be usedto track the program order of ops and manage retirement/flush, forexample.

Ops may be scheduled for execution when the source operands for the opsare ready. In the illustrated embodiment, decentralized scheduling isused for each of the execution units 28A-28B and the LSU 42, e.g. in thereservation stations 24A-24N. Other embodiments may implement acentralized scheduler if desired. Scheduled ops may read their sourceoperands from the register file 30 and/or may have operands forwardedfrom previous ops executed by the execution units 28A-28B and/or LSU 42.The results of ops that have target registers may be written to theregister file 30 and/or forwarded to dependent ops.

The reservation station 24N may also be configured to issue atomicoperations (or at least the load op and store op derived from a givenatomic operation) to the LSU 42 for execution. The load op may be issuedbefore the store op, since it is known that the load op reads the memorylocation before the store op writes the memory location.

Alternatively, the load op and store op may be issued concurrently, andload/store ordering checks in the LSU 42 may ensure the order of theload op and the store op.

The LSU 42 may be configured to execute load/store memory ops.Generally, a memory operation (memory op) may be an instructionoperation that specifies an access to memory (although the memory accessmay be completed in a cache such as the data cache 16). A load memoryoperation may specify a transfer of data from a memory location to aregister (e.g. a “read”), while a store memory operation may specify atransfer of data from a register to a memory location (e.g. a “write”).Load memory operations may be referred to as load memory ops, load ops,or loads; and store memory operations may be referred to as store memoryops, store ops, or stores. In an embodiment, store ops may be executedas a store address op and a store data op. The store address op may bedefined to generate the address of the store, to probe the cache for aninitial hit/miss determination, and to update the store queue 32 withthe address and cache info. Thus, the store address op may have theaddress operands as source operands. The store data op may be defined todeliver the store data to the store queue. Thus, the store data op maynot have the address operands as source operands, but may have the storedata operand as a source operand. In many cases, the address operands ofa store may be available before the store data operand, and thus theaddress may be determined and made available earlier than the storedata. In some embodiments, it may be possible for the store data op tobe executed before the corresponding store address op, e.g. if the storedata operand is provided before one or more of the store addressoperands. While store ops may be executed as store address and storedata ops in some embodiments, other embodiments may not implement thestore address/store data split.

The execution circuit 34 in the LSU 42 may execute the load/store opsissued by the reservation station 24N. The execution circuit 34 mayaccess the data cache 16 to determine hit/miss for the load/store ops,and to forward data for loads. The execution circuit 34 may check thestore queue 32 for ordering issues with loads being executed, as well asto forward data from a store or stores in the store queue 32 for a loadthat is younger than the store or stores and matches the address of thestore(s) in the store queue 32. Similarly, the execution circuit 34 maycheck the load queue 30 to detect ordering issues for a store beingexecuted. When ordering issues are detected, if the op being executed isthe op that needs to finish later than an op in one of the queues 30-32,an internal retry of the op may be used to properly order the ops. Ifthe op in the queue 30-32 needs to finish later than an op that is beingexecuted, a flush is often needed (e.g. if a load has forwarded data andis in the load queue 30, and an older store executes and updates thesame data or a portion of the data, then incorrect data has beenforwarded).

The LSU 42 may also be configured to execute at least the load op andthe store op that are part of an atomic instruction/operation. In someembodiments, the LSU 42 may also execute the data operation on the loaddata. For example, for a compare and swap atomic operation, the dataoperation is a comparison and may be implemented by including acomparator in the LSU 42 (or sharing one of the other comparators used,e.g. for address comparisons). In other embodiments, the data operationmay be performed in the execution units 28A-28B. For example, a morecomplex arithmetic operation such as an add and compare or the like maybe implemented in the execution units 28A-28B.

In general, the atomic operation may comprise or specify a loadoperation from a memory location, a data operation on first data fromthe load operation (the “load data”), and a store operation to writesecond data (the “store data”) to the memory location. The storeoperation may be conditional based on a result of the data operation.That is, the write to the memory location of the second data may beperformed, or occur, conditionally based on the result of the dataoperation. The atomic operation is defined to complete unsuccessfullybased on the store operation/write not being performed, and to completesuccessfully based on the store operation/write being performed.

For example, a compare and swap atomic operation may compare the loaddata to an operand of the compare and swap instruction. If thecomparison is equal, the store data is written to the memory location,completing successfully. If the comparison is not equal, the store datais not written to the memory location, completing unsuccessfully. Testand set/clear operations may test for a predetermined value in the loaddata (e.g. zero for test and set, one for test and clear) and performthe store data write if the comparison is equal or not perform the storedata write if the comparison is not equal. An arithmetic result may alsobe compared to an operand or a predefined value (e.g. zero) to producethe condition for the store operation. Alternatively, condition codesdescribing the arithmetic result may produce the condition (e.g. carry,overflow, negative, zero, etc.).

The source of the second data for the store operation may vary based onthe definition of the atomic operation. In some cases, the second datamay be an operand of the atomic instruction. For example, a compare andswap instruction may include an operand specifying the second data to beconditionally written (e.g. a register address of the registercontaining the data). In other cases, the second data may be apredetermined value implicit in the definition of the instruction. Forexample, a test and set or test and clear instruction may implicitlyspecify a one or zero, respectively, as the predetermined value. Instill other cases, the second data may be the result of the dataoperation (e.g. in the case of an arithmetic operation performed on theload data).

The atomic predictor circuit 36 may be configured to predict the successor lack of success of an atomic operation (e.g. whether or not theatomic operation will complete successfully or complete unsuccessfully).The prediction may also be referred to as a pass/fail prediction. Forexample, a pass prediction may be a prediction that the atomic operationwill complete successfully, and a fail prediction may be a predictionthat the atomic operation will complete unsuccessfully. The atomicpredictor circuit 36 may track the execution of previous atomicoperations to generate the prediction. In various embodiments, theatomic predictor circuit 36 may track the execution of previous atomicoperations globally, or may track atomic operations separately based ona differentiation of the atomic operations. For example, the fetchaddress of the atomic operations may be a factor in the differentiation(e.g. hashed to form the index, or used directly as an index to apredictor memory). Operands or operand identifiers of the atomicoperation (e.g. register addresses or the values provided from theregisters) may be a factor in the differentiation. Any combination offactors may be used as differentiators in various embodiments.

In an embodiment, the atomic predictor circuit 36 may base theprediction on additional factors such as the value of one or moreoperands. For example, for a compare and swap atomic operation, thevalue to be compared to the load data may be a factor in the prediction.If the value is zero or one, for example, it may be more likely to passthan if the value is another value (which might be a counter or othervalue that is being approached through multiple iterations). The type ofatomic operation may be a factor as well (e.g. there may be multipleforms of the compare and swap instruction or other atomic instruction,and some forms may be more likely to pass than others).

The store queue 32 may queue store ops that have been executed (e.g.probed the cache) and are awaiting commit (e.g. once a given store op isretired, or ready to be retired, in various embodiments). Generally, astore may be committed when the processor 12 has at least determinedthat the store is guaranteed to update the target memory location (e.g.the store cannot be flushed due to an interrupt, architected fault orexception, or microarchitectural exception). In an embodiment, a storemay be committed when the store is retired by the processor 12. The LSU42/execution circuit 34 may forward data from the store queue 32 foryounger load ops. In the case that the store has an address matching theload address but does not have data available, the LSU 42/executioncircuit 34 may retry the load based on the store queue 32 match and waitfor store data to become available. The store queue 32 may also be usedto detect ordering issues with loads.

The store queue 32 may also store an indication of the prediction fromthe atomic predictor circuit 36 with the store op that is part of theatomic operation. The forwarding of the store data for a subsequent loadoperation to the same memory location, or younger load operation, may bebased on the prediction as well as the address matching. If theprediction is successful completion (or pass), the store queue 32 mayforward the store data for the subsequent load operation. If theprediction is unsuccessful completion (or fail), the store queue 32 mayprevent the forwarding even though the addresses match and the storedata is available in the store queue 32. For example, the load may beretried and may be stalled in the load queue 30 until at least the storeoperation is removed from the store queue 32 (e.g. due to commit or dueto the store operation completing unsuccessfully). In an embodiment, theload may be stalled until all older store operations are drained fromthe store queue. In another embodiment, the load may be tagged with thestore queue entry and may be replayed when the store queue entry isfreed. In still another embodiment, the load may be replayed, and may beretried on each replay until it does not hit in the store queue 32 anylonger.

In an embodiment, the prediction may also be used to affect the cachestate in the DCache 16 for the cache line accessed by an atomic op. Ifan atomic op completes successfully, the store will write the DCache 16.Accordingly, when an atomic op executes, the processor 12 may attempt toobtain an exclusive state of the cache line (e.g. exclusive may berequested for a cache miss, or a change from shared to exclusive statemay be requested for a cache hit in the shared state). When the store isperformed successfully, the cache line may be updated without furthercommunication. However, if the atomic op is predicted to beunsuccessful, the exclusive state may not be needed and may reduceperformance overall in the system if there is contention for the cacheline. Thus, the processor 12 may attempt to obtain a shared state forthe cache line (e.g. the cache line may be requested in shared state fora cache miss, or may remain in shared state for a cache hit), when anatomic op is predicted to be unsuccessful.

In an embodiment, the prediction may also be used to affect other partsof the processor 12. For example, if the result of the atomic op affectsa subsequent compare branch, the branch prediction may be more likely tobe incorrect. The prediction may be used to throttle the upstreampipeline stages of the processor 12 to save power, since a mispredictioncauses a flush of the processor 12. An embodiment may even use theatomic op prediction in the branch prediction unit 26 as well (e.g. thebranch prediction unit 26 may use the atomic op prediction ofunsuccessful (store op will not write the memory location) in asubsequent branch prediction.

Similarly, the load queue 30 may queue load ops that have been executed.The load queue 30 may include load ops that have been retried and are tobe executed again, either as soon as possible or after occurrence of asubsequent event related to the reason that the retry was detected. Theload queue 30 may also be used by the LSU 42 to detect ordering issueswith stores, so that loads that have completed (e.g. irreversiblyforwarded data to a target) and have an ordering issue may be flushed.The ordering issues detected using the load queue 30 and the store queue32 may include memory ordering model issues and/or issues related to thecoherence of memory locations that are read by load ops and written bystore ops in the same thread or code sequence being executed by theprocessor 12.

The execution units 28A-28B may include any types of execution units invarious embodiments. For example, the execution units 28A-28B mayinclude integer, floating point, and/or vector execution units. Integerexecution units may be configured to execute integer ops. Generally, aninteger op is an op which performs a defined operation (e.g. arithmetic,logical, shift/rotate, etc.) on integer operands. Integers may benumeric values in which each value corresponds to a mathematicalinteger. The integer execution units may include branch processinghardware to process branch ops, or there may be separate branchexecution units.

Floating point execution units may be configured to execute floatingpoint ops. Generally, floating point ops may be ops that have beendefined to operate on floating point operands. A floating point operandis an operand that is represented as a base raised to an exponent powerand multiplied by a mantissa (or significand). The exponent, the sign ofthe operand, and the mantissa/significand may be represented explicitlyin the operand and the base may be implicit (e.g. base 2, in anembodiment).

Vector execution units may be configured to execute vector ops. Vectorprocessing may be characterized by performing the same processing onsignificant amounts of data, where each datum is a relatively smallvalue (e.g. 8 bits or 16 bits, compared to 32 bits to 64 bits for aninteger). Thus, vector ops often include single instruction-multipledata (SIMD) or vector operations on an operand that represents multipledata items.

Thus, each execution unit 28A-28B may comprise hardware configured toperform the operations defined for the ops that the particular executionunit is defined to handle. The execution units may generally beindependent of each other, in the sense that each execution unit may beconfigured to operate on an op that was issued to that execution unitwithout dependence on other execution units. Viewed in another way, eachexecution unit may be an independent pipe for executing ops. Differentexecution units may have different execution latencies (e.g., differentpipe lengths). Additionally, different execution units may havedifferent latencies to the pipeline stage at which bypass occurs, andthus the clock cycles at which speculative scheduling of dependent opsoccurs may vary based on the type of op and execution unit 28 that willbe executing the op.

It is noted that any number and type of execution units 28A-28B may beincluded in various embodiments, including embodiments having oneexecution unit and embodiments having multiple execution units.Similarly, there may be more than one LSU 42.

A cache line may be the unit of allocation/deallocation in a cache. Thatis, the data within the cache line may be allocated/deallocated in thecache as a unit. Cache lines may vary in size (e.g. 32 bytes, 64 bytes,128 bytes, or larger or smaller cache lines). Different caches may havedifferent cache line sizes. The ICache 18 and DCache 16 may each be acache having any desired capacity, cache line size, and configuration.There may be more additional levels of cache between the DCache16/ICache 18 and the main memory, in various embodiments.

At various points, ops are referred to as being younger or older thanother ops. A first operation may be younger than a second operation ifthe first operation is subsequent to the second operation in programorder. Similarly, a first operation may be older than a second operationif the first operation precedes the second operation in program order.

FIG. 2 is a flowchart illustrating certain operations of one embodimentof the processor 12 (and portions thereof). While the blocks are shownin a particular order for ease of understanding, other orders may beused. Some blocks or combinations of blocks may be independent of eachother and thus may be performed in parallel or in any order. Forexample, in FIG. 2, the combination of the blocks 62, 64, 66, and 68 maybe independent of the combination of the blocks 50, 52, 54, 56, 58, and60. Blocks may be performed in parallel in combinatorial logic in theprocessor 12. Blocks, combinations of blocks, and/or the flowchart as awhole may be pipelined over multiple clock cycles. The processor 12 maybe configured to implement the operation shown in FIG. 2.

When the processor 12 (and more particularly the LSU 42) executes a loadop, the LSU 42 may compare the address of the data being read by theload to the addresses of data being written by the stores in the storequeue 32 to check for a hit. If the load op is a hit on a store op inthe store queue 32 (e.g. the addresses match or overlap and the store opis older than the load op) (decision block 50, “yes” leg), it ispossible that the store queue 32 will forward data for the load op (orfor a portion of the load op, if the processor 12/LSU 42 supportspartial store to load forwarding when the addresses overlap but thereare bytes not supplied by the store op). In this case, the load op maybe a subsequent load op with respect to the store op, since the load opis an instruction, or is derived from an instruction that is youngerthan the store op's instruction (or the instruction from which the storeop is derived, e.g. an atomic op).

If the store op is part of an atomic op (decision block 52, “yes” leg)that is predicted to complete successfully (decision block 54, “yes”leg), the store queue 32 may forward the store data from the store queue32 as data for the load op (block 56). Also, if the store op is not partof an atomic op (decision block 52, “no” leg), the store queue mayforward the store data from the store queue 32 (block 56). On the otherhand, if the store op is part of an atomic op (decision block 52, “yes”leg) and the atomic is predicted to complete unsuccessfully (decisionblock 54, “no” leg), the LSU 42 may retry or replay the load op, and maywait for the store queue 32 to drain of older stores before reattemptingthe load op (block 58). Viewed in another way, the LSU 42 may preventthe forwarding of data from the store op to the subsequent load op basedon the prediction that the atomic op will be completed unsuccessfully,even in the event that the forwarding would otherwise have occurred.That is, the LSU 42 may prevent the forwarding of data from the store opto the subsequent load op based on the prediction that the storeoperation will not be performed. When the load op is replayed (e.g.after the store operation has been removed from the store queue 32), itmay hit the DCache 16 and the load data may be forwarded from the DCache16 (block 60). If the load op is a miss in the DCache 16, the load datamay be forwarded form a different cache level (if a hit) or from mainmemory (if a miss in all cache levels). Also, if the load op is not hitin the store queue 32 (decision block 50, “no” leg), the data for theload may be forwarded from the DCache 16 or another cache level/mainmemory (block 60).

As mentioned previously, other embodiments may delay the replayed loaduntil at least the store op associated with the atomic op and that ishit by the replayed load is removed from the store queue 32, rather thanwaiting for a drain. Alternatively, other embodiments may attempt areplay after any entry is removed from the store queue, or may attempt areplay periodically, instead of implementing the logic to wait for theparticular store op that is hit by the load. In still other embodiments,the data that was read from the memory location for the load op from theatomic op may also be captured in the store queue 32 and forwarded forthe subsequent load op based on the prediction that the atomic op willcomplete unsuccessfully. In yet another embodiment, data from the DCache16 may be forwarded for the subsequent load op, prior to the removal ofthe store op from the store queue 32, based on the prediction ofunsuccessful. Such an embodiment effectively ignores the store queue hitwhen the prediction is unsuccessful. The data in the DCache 16 would bethe same as the data read by the load portion of the atomic op.

Additionally, the processor 12/LSU 42 may determine if an atomic op hascompleted (decision block 62). The atomic op may be complete if thestore op from the atomic op is committed, or the store op is not beingperformed based on the result of the data operation, or the store op isnot being performed because atomicity was not maintained over theaffected data between the load op from the atomic op and the store opfrom the atomic op. In some embodiments, the atomicity is guaranteed(e.g. by inhibiting snoops during the time between the load and thestore or between initiation of the store and completion of the store)and the atomic operation may not fail due to lack of atomicity. If theatomic op is completed successfully (decision block 62, “yes” leg anddecision block 64, “yes” leg), the atomic predictor circuit 36 mayupdate to reflect the atomic op that has complete successfully. Variousembodiments will be described in more detail below as examples of theupdate. If the atomic op is completed unsuccessfully (decision block 64,“no” leg) and the store op forwarded data for a subsequent load op(decision block 66, “yes” leg), the atomic predictor circuit 36 mayupdate to reflect the atomic op that has completed unsuccessfully (block68). Again, various embodiments will be described in more detail belowas examples of the update for completing unsuccessfully as well ascompleting successfully. If no atomic op is completing (decision block62, “no” leg) or the atomic op has completed unsuccessfully but did notforward data for a subsequent load (decision block 62, “yes” leg,decision block 64, “no” leg, and decision block 66, “no” leg), then noupdate is made in this embodiment. In other embodiments, an atomic opthat completes unsuccessfully but has not forwarded data may update theprediction as well. The update for completing unsuccessfully withoutforwarding may be the same as the update for completing unsuccessfullywith forwarding, or may be a lesser-weighted update than the update forcompleting unsuccessfully with forwarding, in various embodiments.

By updating the prediction if the atomic operation is unsuccessful andforwards the store data, but not updating the prediction if the atomicoperation is unsuccessful but did not forward the store data, theprediction may be focused on the cases when flushing actually occurs.That is, if the atomic operation fails but the store data was notforwarded, there is no need to flush any instructions and thus theincorrect prediction may have been harmless to performance and powerconsumption.

In an embodiment, a thread including an atomic operation may havedifferent phases of execution in which the result of the atomicoperation may vary based on the phase. For example, a first phase mayinclude the atomic operation resulting in success (store operationperformed), while a second phase may include the atomic operationresulting in failure (store operation not performed). The atomicpredictor circuit 36 may train the prediction(s) to adapt to the changesin execution phase. That is, the atomic predictor circuit 36 maystrengthen a prediction of successful in the first phase, and weaken aprediction of successful in the second phase (adapting to a predictionof unsuccessful as the second phase continues). Similarly, the atomicpredictor circuit 36 may strengthen a prediction of unsuccessful in thesecond phase, and weaken the prediction of unsuccessful in the firstphase (adapting to a prediction of successful as the first phasecontinues).

FIG. 3 is a block diagram of one embodiment of the atomic predictorcircuit 36. In the illustrated embodiment, the atomic predictor circuit36 comprises a control circuit 70 coupled to a register, or counter, 72.The control circuit 70 is coupled to an indication that an atomic op isbeing executed (e.g. from the execution circuit 34) and is configured togenerate a prediction for the atomic op. The control circuit 70 mayprovide an indication of the prediction (e.g. the atomic forwardcontrol, or AFwdCtl, in FIG. 3) to the store queue 32 and may receive anindication of completion (successful or unsuccessful) from the storequeue 32 (e.g. the atomic pass/fail (P/F) in FIG. 3). An atomic pass maybe a completion that is successful, and an atomic fail may be acompletion that is unsuccessful (and forwarded to a subsequent load, inan embodiment).

The register 72 may store a count value (atomic prediction counter, orAPCtr, in FIG. 3), and the control circuit 70 may be configured toupdate the count value based on atomic operations executed in the LSU42. For example, the control circuit 70 may be configured to incrementthe count value based on a detection that an atomic operation completedsuccessfully. The control circuit 70 may be configured to decrement thecount value based on a detection that the atomic operation completedunsuccessfully and further based on the store queue having forwardedstore data (e.g. the second data) to a subsequent load operation. Thecontrol circuit 70 may also be configured not to modify the count valuebased on a detection that the atomic operation completed unsuccessfullyand further based on the store queue having not forwarded the seconddata.

The control circuit 70 may be configured to compare the count value to athreshold value to predict the atomic operation indicated by the atomicop input to the control circuit 70. In the above described embodiment,the control circuit 70 may be configured to compare the count value to athreshold value and to predict a successful completion if the countvalue is greater than the threshold value (or greater than or equal to).Other embodiments may decrement the count value on successful atomic opsand increment the count value on unsuccessful, the compare may be forthe count value to be less than the threshold value (or less than orequal to the threshold value). The threshold value may be fixed orprogrammable, in various embodiments.

In one embodiment, the count value may be initialized to the maximumvalue that it can reach, and thus the number of failed atomic ops priorto blocking forwarding may be based on a difference between the maximumvalue and the threshold value. Accordingly, in cases in which atomic opsthat complete unsuccessfully are not common, the store to loadforwarding from the store op derived from the atomic op may beunaffected but cases in which completing unsuccessfully is more commonmay result in forwarding being prevented. Other embodiments may selectother initialization values. Additionally, embodiments that decrementbased on completion of the atomic operation successfully and incrementbased on completion of the atomic operation unsuccessfully mayinitialize the counter to zero or a low value.

FIG. 4 is a flowchart illustrating certain operation of one embodimentof the atomic predictor circuit 36 shown in FIG. 3. While the blocks areshown in a particular order for ease of understanding, other orders maybe used. Some blocks or combinations of blocks may be independent ofeach other and thus may be performed in parallel or in any order. Forexample, in FIG. 4, the combination of the blocks 88, 90, 92, 94, and 96may be independent of the combination of the blocks 80, 82, 84, and 86.Blocks may be performed in parallel in combinatorial logic in thecontrol circuit 70. Blocks, combinations of blocks, and/or the flowchartas a whole may be pipelined over multiple clock cycles. The controlcircuit 70 may be configured to implement the operation shown in FIG. 4.

If the control circuit 70 receives an indication that an atomic op isbeing executed (decision block 80, “yes” leg) and the APCtr is greaterthan a threshold amount (decision block 82, “yes” leg), the controlcircuit 70 may be configured to predict successful for the atomic op(block 84). For example, the control circuit 70 may assert the AFwdCtl(binary 1) to the store queue 32. If the APCtr is less than thethreshold (decision block 82, “no” leg), the control circuit 70 may beconfigured to predict unsuccessful for the atomic op (block 86). Forexample, the control circuit 70 may deassert (binary 0) the AFwdCtl tothe store queue 32. The store queue 32 may store the AFwdCtl value inthe store queue 32 with the store op portion of the atomic op. It isnoted that, since the implementation illustrated in FIGS. 3-4 is aglobal counter-based system that is not tied to a particular instance ofan atomic op, the control circuit 70 may be configured to implement theoutput AFwdCtl continuously based on the comparison of the APCtr and thethreshold value (e.g. it need not be based on receiving an indicationthat the atomic op is being executed).

The store queue 32 may also signal when the store portion of atomic opsare completing, and whether the completion is successful or unsuccessful(e.g. AtomicP/F in FIG. 3). If an atomic op is complete (decision block88, “yes” leg) and is successful (decision block 90, “yes” leg), thecontrol circuit 70 may be configured to increment the APCtr (block 92).If the atomic op completes unsuccessfully and the store op forwardeddata to a subsequent load op (decision block 90, “no” leg and decisionblock 94, “yes” leg), the control circuit 70 may decrement the APCtr(block 96). If the atomic op completes unsuccessfully and the store opdid not forward data to a subsequent load op (decision block, 90, “no”leg and decision block 94, “no” leg), the control circuit 70 may beconfigured not to modify the APCtr. The APCtr may be a saturatingcounter, saturating at the maximum value for increments and saturatingat zero for decrements (e.g. the counter may not overflow or underflow).

The embodiment of FIGS. 3-4 implements a global prediction scheme,tracking results of atomic ops collectively and basing predictions onthe collective results. Other embodiments may attempt to trackingseparate predictions for atomic ops (although there may some aliasingbetween instances of atomic ops that map to the same entry in aprediction memory as discussed below). FIGS. 5-6 are an exampleembodiment of such an implementation.

FIG. 5 is a block diagram of an embodiment of the atomic predictorcircuit 36 comprising a control circuit 100 and predictor memory 102coupled to the control circuit 100. The control circuit 100 is coupledto an indication that an atomic op is being executed (e.g. from theexecution circuit 34) along with an index to the predictor memory 102(or data from which the index may be calculated). For example, a portionof the fetch address of the atomic instruction corresponding to theatomic op may be used as an index, or a portion or all of the fetchaddress may be hashed to produce the index. Other information from theatomic op maybe used along with or instead of the fetch address togenerate the index (hashed or unhashed), as desired. The control circuit100 may be configured to generate the prediction for the atomic op fromdata in the predictor memory 102 stored at the index. That is, thepredictor memory 100 may comprise a plurality of entries, and an entrymay be selected from which to read the prediction or data to use to formthe prediction. The control circuit 100 may provide an indication of theprediction (e.g. the atomic forward control, or AFwdCtl, in FIG. 5) tothe store queue 32 and may receive an indication of completion(successful or unsuccessful) from the store queue 32 (e.g. the atomicpass/fail (P/F) in FIG. 5). The store queue 32 may also provide theindex of the entry used to form the prediction, or the datacorresponding to the completing atomic op that is used to generate theindex. An atomic pass may be a completion that is successful, and anatomic fail may be a completion that is unsuccessful (and forwarded to asubsequent load, in an embodiment).

As mentioned above, the prediction memory 102 may have a plurality ofentries, and a given entry of the plurality of entries may store aprediction value from which the predictor circuit is configured togenerate predictions for respective atomic operations. The predictionvalue may be, e.g. a saturating counter that is incremented forsuccessful atomic operations and decremented for unsuccessful atomicoperations (or vice versa). The most significant bit of the counter maybe used as a prediction, or the value of the counter may compared to oneor more threshold values to determine the predictions. The thresholdvalue may be fixed or programmable, in various embodiments. The controlcircuit 100 may be configured to select a first entry of the pluralityof entries based on the atomic operation and to use a first predictionvalue in the first entry to generate the prediction for the atomicoperation. In some embodiments, the atomic predictor circuit 36 may be amulti-table predictor and multiple entries may be read, from which aprediction value may be selected according to the multi-table selectioncriteria implemented by the predictor. In some embodiments, thepredictor memory 102 may be a set associative memory and tag comparisonsmay be used to select an entry from the indexed set.

The control circuit 100 may also be configured to select the first entrybased on completing the atomic operation, and control circuit 100 may beconfigured to update the first prediction value based on whether theatomic operation completed successfully or completed unsuccessfully.That is, the control circuit 100 may be configured to update theprediction based on whether the store op is performed or not performed.As mentioned previously, the prediction may be updated in the case thatthe store op is not performed, and the store data was forwarded for asubsequent load op.

FIG. 6 is a flowchart illustrating certain operation of one embodimentof the atomic predictor circuit 36 shown in FIG. 5. While the blocks areshown in a particular order for ease of understanding, other orders maybe used. Some blocks or combinations of blocks may be independent ofeach other and thus may be performed in parallel or in any order. Forexample, in FIG. 6, the combination of the blocks 120 and 122 may beindependent of the combination of the blocks 110, 112, 114, 116 and 118.Blocks may be performed in parallel in combinatorial logic in thecontrol circuit 100. Blocks, combinations of blocks, and/or theflowchart as a whole may be pipelined over multiple clock cycles. Thecontrol circuit 100 may be configured to implement the operation shownin FIG. 6.

If an atomic op is being executed (decision block 110, “yes” leg), thecontrol circuit 100 may form the index or use the received index to readthe predictor memory 102. In an embodiment, the entries in the predictormemory 102 may be tagged with information identifying the atomic opassigned to the entry (e.g. a portion of the fetch address not used forthe index, information from the atomic op itself such as opcode, operandaddresses, etc., etc.) and corresponding information may be comparedfrom the executing atomic op to determine if there is a hit in the entry(decision block 112). In other embodiments, aliasing among atomic opsthat index to the same entry is permitted and there is an assumption ofa hit in the entry. In either the case of a hit or presumed hit(decision block 112, “yes” leg), the control circuit 100 may beconfigured to predict the atomic op based on the contents of the entry(block 114). If there is a miss in the entry (decision block 112, “no”leg), the control circuit 110 may be configured to predict that theatomic op will be successful (block 116) and may allocate an entry inthe predictor memory 102 for the atomic op (block 118). In anembodiment, the predictor memory 102 may include a plurality of entriesat a given index location, and an entry may be allocated based on anyselection mechanism (e.g. least recently used (LRU) or an LRU variant,etc.)

If the store queue 32 indicates completion of an atomic operation(decision block 120), the control circuit 100 may be configured to readthe entry associated with the completing atomic op and may train theentry based on the “completed successfully” (pass) or “completedunsuccessfully and forwarded to a subsequent load op” (fail) result ofthe completing atomic op (block 112).

System

Turning next to FIG. 7, a block diagram of one embodiment of a system150 is shown. In the illustrated embodiment, the system 150 includes atleast one instance of a system on a chip (SOC) 152 coupled to one ormore peripherals 154 and an external memory 158. A power supply 156 isprovided which supplies the supply voltages to the SOC 152 as well asone or more supply voltages to the memory 158 and/or the peripherals154. In some embodiments, more than one instance of the SOC 152 may beincluded (and more than one memory 158 may be included as well). The SOC152 may include one or more instances of the processor 12 as illustratedin FIG. 1.

The peripherals 154 may include any desired circuitry, depending on thetype of system 150. For example, in one embodiment, the system 150 maybe a mobile device (e.g. personal digital assistant (PDA), smart phone,etc.) and the peripherals 154 may include devices for various types ofwireless communication, such as Wi-Fi, Bluetooth, cellular, globalpositioning system, etc. The peripherals 154 may also include additionalstorage, including RAM storage, solid state storage, or disk storage.The peripherals 154 may include user interface devices such as a displayscreen, including touch display screens or multitouch display screens,keyboard or other input devices, microphones, speakers, etc. In otherembodiments, the system 150 may be any type of computing system (e.g.desktop personal computer, laptop, workstation, net top etc.).

The external memory 158 may include any type of memory. For example, theexternal memory 158 may be SRAM, dynamic RAM (DRAM) such as synchronousDRAM (SDRAM), double data rate (DDR, DDR2, DDR3, etc.) SDRAM, RAIVIBUSDRAM, low power versions of the DDR DRAM (e.g. LPDDR, mDDR, etc.), etc.The external memory 158 may include one or more memory modules to whichthe memory devices are mounted, such as single inline memory modules(SIMMs), dual inline memory modules (DIMMs), etc. Alternatively, theexternal memory 158 may include one or more memory devices that aremounted on the SOC 152 in a chip-on-chip or package-on-packageimplementation.

Computer Readable Storage Medium

Turning now to FIG. 8, a block diagram of one embodiment of a computerreadable storage medium 200 is shown. Generally speaking, a computeraccessible storage medium may include any storage media accessible by acomputer during use to provide instructions and/or data to the computer.For example, a computer accessible storage medium may include storagemedia such as magnetic or optical media, e.g., disk (fixed orremovable), tape, CD-ROM, DVD-ROM, CD-R, CD-RW, DVD-R, DVD-RW, orBlu-Ray. Storage media may further include volatile or non-volatilememory media such as RAM (e.g. synchronous dynamic RAM (SDRAM), RambusDRAM (RDRAM), static RAM (SRAM), etc.), ROM, or Flash memory. Thestorage media may be physically included within the computer to whichthe storage media provides instructions/data. Alternatively, the storagemedia may be connected to the computer. For example, the storage mediamay be connected to the computer over a network or wireless link, suchas network attached storage. The storage media may be connected througha peripheral interface such as the Universal Serial Bus (USB).Generally, the computer accessible storage medium 200 may store data ina non-transitory manner, where non-transitory in this context may referto not transmitting the instructions/data on a signal. For example,non-transitory storage may be volatile (and may lose the storedinstructions/data in response to a power down) or non-volatile.

The computer accessible storage medium 200 in FIG. 8 may store adatabase 204 representative of the SOC 152. Generally, the database 204may be a database which can be read by a program and used, directly orindirectly, to fabricate the hardware comprising the SOC 152. Forexample, the database may be a behavioral-level description orregister-transfer level (RTL) description of the hardware functionalityin a high-level design language (HDL) such as Verilog or VHDL. Thedescription may be read by a synthesis tool which may synthesize thedescription to produce a netlist comprising a list of gates from asynthesis library. The netlist comprises a set of gates which alsorepresent the functionality of the hardware comprising the SOC 152. Thenetlist may then be placed and routed to produce a data set describinggeometric shapes to be applied to masks. The masks may then be used invarious semiconductor fabrication steps to produce a semiconductorcircuit or circuits corresponding to the SOC 152. Alternatively, thedatabase 204 on the computer accessible storage medium 200 may be thenetlist (with or without the synthesis library) or the data set, asdesired.

While the computer accessible storage medium 200 stores a representationof the SOC 152, other embodiments may carry a representation of anyportion of the SOC 152, as desired, including the processor 12, anysubset of the processor 12 or portions thereof, etc. The database 204may represent any portion of the above.

FIG. 9 is a flowchart illustrating certain operations of one embodimentof the processor 12 shown in FIG. 1. In the illustrated embodiment, ifthe processor 12 executes an atomic operation (decision block 130, “yes”leg) and the atomic operation is predicted successful (decision block132, “yes” leg), the processor 12 may be configured to attempt to obtaina cache line addressed by the atomic operation in the exclusive state inthe DCache 16 (block 134). If the processor 12 executes an atomicoperation (decision block 130, “yes” leg) and the atomic operation ispredicted unsuccessful (decision block 132, “no” leg), the processor 12may be configured to throttle one or more pipeline stages (block 136).Additionally, if the processor 12 executes an atomic operation (decisionblock 130, “yes” leg) and the atomic operation is predicted unsuccessful(decision block 132, “no” leg), the processor 12 may be configured toattempt to obtain the cache line addressed by the atomic operation inthe shared state in the DCache 16 (block 138).

In accordance with the above description, load/store unit may comprise apredictor circuit and a store queue coupled to the predictor circuit.The predictor circuit may be configured to generate a prediction ofwhether or not an atomic operation executed by the load/store unit willcomplete successfully. The atomic operation may specify a load operationfrom a memory location, a data operation on first data from the loadoperation, and a store operation to write second data to the memorylocation, wherein the store operation is conditional on a result of thedata operation. The atomic operation may be defined to completeunsuccessfully based on the store operation not being performed. Thestore queue may be configured to store the store operation and anindication of the prediction from the predictor circuit. The store queuemay be configured to forward the second data to a subsequent loadoperation to the memory location based on the indication indicating aprediction of successful completion by the predictor circuit. The storequeue is also configured to prevent forwarding of the second data basedon the indication indicating a prediction of unsuccessful completion bythe predictor circuit. In an embodiment, the source of the second datais one of an operand of an atomic instruction corresponding to theatomic operation, a predetermined value, or the result of the dataoperation. In an embodiment, the predictor circuit comprises a registerconfigured to store a count value. The predictor circuit may beconfigured to update the count value based on atomic operations executedin the load/store unit. The predictor circuit may be configured toincrement the count value based on a detection that the atomic operationcompleted successfully, in an embodiment. The predictor circuit may beconfigured to decrement the count value based on a detection that theatomic operation completed unsuccessfully and further based on the storequeue having forwarded the second data to the subsequent load operation,in an embodiment. In an embodiment, the predictor circuit may beconfigured not to modify the count value based on a detection that theatomic operation completed unsuccessfully and further based on the storequeue having not forwarded the second data. In an embodiment, thepredictor circuit is configured to compare the count value to athreshold value to predict the atomic operation. In another embodiment,the predictor circuit comprises a memory having a plurality of entries,and a given entry of the plurality of entries stores a prediction valuefrom which the predictor circuit is configured to generate predictionsfor respective atomic operations. The predictor circuit may beconfigured to select a first entry of the plurality of entries based onthe atomic operation and to use a first prediction value in the firstentry to generate the prediction for the atomic operation. In anembodiment, the predictor circuit is configured to select the firstentry based on completing the atomic operation. The predictor circuitmay be configured to update the first prediction value based on whetherthe atomic operation completed successfully or completed unsuccessfully.

In an embodiment, a processor comprises a reservation station coupled toa load/store unit. The reservation station may be configured to issue anatomic operation to be executed, wherein the atomic operation specifiesa load operation from a memory location, a data operation on first datafrom the load operation, and a store operation to conditionally writesecond data to the memory location based on a result of the dataoperation. The load/store unit comprises a predictor circuit that may beconfigured to generate a prediction of whether or not the storeoperation will write the memory location. The load store unit furthercomprises a store queue configured to store the store operation, thesecond data, and an indication of the prediction from the predictorcircuit. The wherein the store queue may be configured to forward thesecond data to a subsequent load operation to the memory location basedon a prediction that the store operation will write the memory location.The store queue may be further configured to prevent a forward of thesecond data based on a prediction that the store operation will notwrite the memory location. In an embodiment, the load/store unit may beconfigured to delay the subsequent load operation until at least thestore operation is removed from the store queue. In an embodiment, theprocessor further comprises a data cache. The load/store unit may beconfigured to forward data from the data cache for the subsequent loadoperation after the store operation is removed from the store queue. Inan embodiment, the predictor circuit comprises a register configured tostore a count value. The predictor circuit may be configured to updatethe count value based on atomic operations executed in the load/storeunit and to predict atomic operations based on the count value. In anembodiment, the predictor circuit may configured to compare the countvalue to a threshold value to predict the atomic operation. In anotherembodiment, the predictor circuit comprises a memory having a pluralityof entries. A given entry of the plurality of entries stores aprediction value from which the predictor circuit is configured togenerate predictions for respective atomic operations. The predictorcircuit may be configured to select a first entry of the plurality ofentries based on the atomic operation and to use a first predictionvalue in the first entry to generate the prediction for the atomicoperation. The predictor circuit may be configured to select the firstentry based on a fetch address of the atomic operation. In anembodiment, the predictor circuit may be configured to select the firstentry based on detection of a completion of the atomic operation. Thepredictor circuit may be configured to update the first prediction valuebased on whether or not the store operation was performed.

In an embodiment, a method may comprise executing an atomic operation ina load/store unit, wherein the atomic operation includes a loadoperation from a memory location, a data operation preformed on firstdata read from the memory location, and a store operation to writesecond data to the memory location based on a result of the dataoperation; predicting whether or not the store operation will beperformed; and selectively forwarding the second data from a store queuebased on the predicting. In an embodiment, the method further comprisesupdating data used to perform the predicting based on whether or notatomicity was maintained.

Numerous variations and modifications will become apparent to thoseskilled in the art once the above disclosure is fully appreciated. It isintended that the following claims be interpreted to embrace all suchvariations and modifications.

1-20. (canceled)
 21. A predictor circuit comprising: a storage circuitconfigured to store data indicative of previous executions of atomicoperations, wherein a given atomic operation specifies a load operationfrom a memory location, a data operation on first data from the loadoperation, and a store operation to write second data to the memorylocation, wherein the store operation is conditional on a result of thedata operation, and wherein the given atomic operation is defined tocomplete unsuccessfully based on the store operation not beingperformed; and a control circuit coupled to the storage circuit and toan input indicating that a current execution of an atomic operation isoccurring, wherein the control circuit is configured to generate aprediction of whether or not the atomic operation will completesuccessfully based on the data from the storage circuit, and wherein thecontrol circuit is configured to output the prediction.
 22. Thepredictor circuit as recited in claim 21 wherein the control circuit iscoupled to a second input indicating whether or not the currentexecution completes successfully, and wherein the control circuit isconfigured to update the data based on the second input.
 23. Thepredictor circuit as recited in claim 22 wherein the storage circuitcomprises a register and the data is a count indicative of a number ofprevious successful/unsuccessful executions of atomic operations, andwherein the control circuit is configured to modify the count to updatethe data.
 24. The predictor circuit as recited in claim 23 wherein thecontrol circuit is configured to compare the count to a threshold togenerate the prediction.
 25. The predictor circuit as recited in claim22 wherein the storage circuit comprises a memory including a pluralityof entries, wherein the control circuit is configured to generate anindex to select one of the plurality of entries based on one or morefactors that identify the atomic operation corresponding to the currentexecution, and wherein the control circuit is configured to generate theprediction based on the data stored in the selected entry.
 26. Thepredictor circuit as recited in claim 25 wherein the data comprises asaturating counter, and wherein the control circuit is furtherconfigured to generate the prediction based on a most significant bit ofthe saturating counter.
 27. The predictor circuit as recited in claim 21wherein the control circuit is further configured to base the predictionon one or more factors corresponding to the current execution.
 28. Thepredictor circuit as recited in claim 27 wherein the one or more factorscomprise a value of an operand of the current execution of the atomicoperation.
 29. An apparatus comprising: a predictor circuit configuredto generate a prediction of whether or not an atomic operation willcomplete successfully, wherein the atomic operation specifies a loadoperation from a memory location, a data operation on first data fromthe load operation, and a store operation to write second data to thememory location, wherein the store operation is conditional on a resultof the data operation, and wherein the atomic operation is defined tocomplete unsuccessfully based on the store operation not beingperformed; and an execute circuit coupled to the predictor circuit andconfigured to perform the atomic operation, wherein the execute circuitis configured to associate the prediction from the predictor circuitwith the store operation, and wherein the execute circuit is configuredto select the second data as predicted result data accessed by asubsequent load operation based on the prediction of successfulcompletion by the predictor circuit, and wherein the execute circuit isconfigured to select data from the memory location is the predictedresult data based on the prediction of unsuccessful completion by thepredictor circuit.
 30. The apparatus as recited in claim 29 furthercomprising a store queue coupled to the execute circuit, wherein thestore queue is configured to store the store operation, and wherein thestore queue is configured to store an indication of the prediction fromthe predictor circuit with the store operation, and wherein the storequeue is configured to forward the second data to the subsequent loadoperation based on the indication indicating a prediction of successfulcompletion by the predictor circuit, and wherein the store queue isconfigured to prevent forwarding of the second data based on theindication indicating a prediction of unsuccessful completion by thepredictor circuit.
 31. The apparatus as recited in claim 30 wherein thepredictor circuit comprises a register configured to store a countvalue, and wherein the predictor circuit is configured to update thecount value based on executed atomic operations.
 32. The apparatus asrecited in claim 31 wherein the predictor circuit is configured not tomodify the count value based on a detection that the atomic operationcompleted unsuccessfully and further based on the store queue having notforwarded the second data.
 33. The apparatus as recited in claim 31wherein the predictor circuit is configured to compare the count valueto a threshold value to predict the atomic operation.
 34. The apparatusas recited in claim 29 wherein the predictor circuit comprises a memoryhaving a plurality of entries, wherein a given entry of the plurality ofentries stores a prediction value from which the predictor circuit isconfigured to generate predictions for respective atomic operations,wherein the predictor circuit is configured to select a first entry ofthe plurality of entries based on the atomic operation and to use afirst prediction value in the first entry to generate the prediction forthe atomic operation.
 35. The apparatus as recited in claim 34 whereinthe predictor circuit is configured to select the first entry based oncompleting the atomic operation, and wherein the predictor circuit isconfigured to update the first prediction value based on whether theatomic operation completed successfully or completed unsuccessfully. 36.The apparatus as recited in claim 29 wherein the predictor circuit isfurther configured to base the prediction on one or more factorscorresponding to the atomic operation.
 37. The apparatus as recited inclaim 36 wherein the one or more factors comprise a value of an operandof the atomic operation.
 38. A method comprising: executing an atomicoperation, wherein the atomic operation includes a load operation from amemory location, a data operation preformed on first data read from thememory location, and a store operation to write second data to thememory location based on a result of the data operation; predictingwhether or not the store operation will be performed; and selectivelydetermining that the second data is result data for a subsequent loadoperation based on the predicting.
 39. The method as recited in claim 38wherein selectively determining that the second data is the result datacomprises providing the second data as the result data based onpredicting that the store operation will be performed.
 40. The method asrecited in claim 38 wherein selectively determining that the second datais the result data comprises providing previous data from the memorylocation as the result data based on predicting that the store operationwill not be performed.